#include "random.h"
#include <cassert>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <set>
#include <algorithm>
#include <stdarg.h>
using namespace std;

typedef long long ll;

#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define eprintf(...) fprintf(stderr, __VA_ARGS__)


int main(int argc, char *argv[])
{
	initrand(Time());
	int T = atoi(argv[1]);
	printf("%d\n", T);
	for (int i = 0; i < T; i++)
	{
		int n = 100;
		int m = 100;
		int D = 20000;
		printf("%d %d %d\n", D, n, m);
		for (int j = 0; j < m; j++)
		{
			for (int k = 0; k < n; k++)
			{
				printf("%d ", R(0, 200));
			}
			printf("\n");
		}
		for (int j = 0; j < m; j++)
		{
			for (int k = 0; k < m; k++)
			{
				if (j == k) printf("0 ");
				else printf("%d ", R(0, 100));
			}
			printf("\n");
		}
	}
	return 0;
}